# 获取当前脚本所在目录的绝对路径
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

# 遍历到项目根目录
while [ ! -f "$SCRIPT_DIR/README.md" ] && [ "$SCRIPT_DIR" != "" ]; do
  SCRIPT_DIR="${SCRIPT_DIR%/*}"
done

# 输出项目根目录
PROJECT_ROOT="$SCRIPT_DIR"
echo "项目根目录是: $PROJECT_ROOT"

npm run build
tar -zcvf  dist.tar.gz dist

ssh root@117.72.219.250 'mkdir -p /root/nginx/html/erp'
scp -r dist.tar.gz root@117.72.219.250:/root/nginx/html/erp
ssh root@117.72.219.250 'cd /root/nginx/html/erp;tar -zxvf dist.tar.gz'
